<template>
  <div class="commentItem">

      <myci v-if='commentParent.parent'
      :commentParent='commentParent.parent'
       @sendComment='sendSub'>
      </myci>


    <div class="top">
      <div class="left">
        <span>{{commentParent.user.nickname}}</span> &nbsp;&nbsp;&nbsp;
        <span>2分钟前</span>
      </div>
      <span @click="sendSub(commentParent)">回复</span>
    </div>
    <div class="bottom">{{commentParent.content}}</div>
  </div>
</template>

<script>
export default {
    // 我们永远不能在一个组件中引入组件自身，否则报错
    // 为组件设置name属性,我们就可能通过这个属性值使用当前组件.类似注册组件
    name:'myci',
    props:{
      commentParent:{
          type:Object
      }  
    },
    methods: {
      sendSub(value){
        this.$emit('sendComment',value)
      }
    }
};
</script>

<style lang="less" scoped>
.commentItem {
  border: 1px solid #ccc;
  padding: 5px;
  margin-top: 10px;
  .top {
    font-size: 12px;
    color: #aaa;
    display: flex;
    justify-content: space-between;
  }
  .bottom {
    font-size: 13px;
    line-height: 40px;
  }
}
</style>